/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GameplayForm.java
 *
 * Created on Jun 18, 2011, 12:24:39 AM
 */
package GUI;

import MiddleLayer.ClientProcessing;
import MiddleLayer.ClientServerMessenger;

/**
 *
 * @author Green
 */
public class GameplayForm extends javax.swing.JFrame {

    //cái game nó phụ thuộc vào panel này
    private GamePanel gamePanel;
    private Game game;

    /** Creates new form GameplayForm */
    public GameplayForm(ClientProcessing clientMessenger) {
        initComponents();
        
        this.setSize(1024, 760);

        game = new Hearts();
        gamePanel = new GamePanel(game);
        game.setup(gamePanel, clientMessenger);
        clientMessenger.setup(BottomPanel, (Hearts)game);//BottomPanel chứa cả khung chat và khung hiển thị thông tin
        this.MainContent.add(gamePanel);
        this.validate();

        gamePanel.repaint();
        gamePanel.requestFocus();
        gamePanel.start();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        MainContent = new javax.swing.JPanel();
        BottomPanel = new javax.swing.JPanel();
        pnlChatting = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        ChatContent = new javax.swing.JTextArea();
        txtMessageInput = new javax.swing.JTextField();
        btnSend = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        pnlClientInfo = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        MainMenu = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Hearts");
        setResizable(false);

        MainContent.setName("MainContent"); // NOI18N
        MainContent.setPreferredSize(new java.awt.Dimension(1024, 600));

        javax.swing.GroupLayout MainContentLayout = new javax.swing.GroupLayout(MainContent);
        MainContent.setLayout(MainContentLayout);
        MainContentLayout.setHorizontalGroup(
            MainContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1024, Short.MAX_VALUE)
        );
        MainContentLayout.setVerticalGroup(
            MainContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 609, Short.MAX_VALUE)
        );

        BottomPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        BottomPanel.setName("BottomPanel"); // NOI18N

        pnlChatting.setName("pnlChatting"); // NOI18N

        ChatContent.setColumns(20);
        ChatContent.setEditable(false);
        ChatContent.setRows(4);
        jScrollPane1.setViewportView(ChatContent);

        btnSend.setText("Send");

        javax.swing.GroupLayout pnlChattingLayout = new javax.swing.GroupLayout(pnlChatting);
        pnlChatting.setLayout(pnlChattingLayout);
        pnlChattingLayout.setHorizontalGroup(
            pnlChattingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlChattingLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlChattingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 524, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlChattingLayout.createSequentialGroup()
                        .addComponent(txtMessageInput, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSend)))
                .addContainerGap())
        );
        pnlChattingLayout.setVerticalGroup(
            pnlChattingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlChattingLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlChattingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtMessageInput, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSend)))
        );

        BottomPanel.add(pnlChatting);

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        BottomPanel.add(jSeparator1);

        pnlClientInfo.setName("pnlClientInfo"); // NOI18N
        pnlClientInfo.setPreferredSize(new java.awt.Dimension(440, 100));

        jLabel1.setText("jLabel1");

        jLabel2.setText("jLabel2");

        jLabel3.setText("jLabel3");

        jLabel4.setText("jLabel4");

        jLabel5.setText("jLabel5");

        jLabel6.setText("jLabel6");

        jLabel7.setText("jLabel7");

        jLabel8.setText("jLabel8");

        javax.swing.GroupLayout pnlClientInfoLayout = new javax.swing.GroupLayout(pnlClientInfo);
        pnlClientInfo.setLayout(pnlClientInfoLayout);
        pnlClientInfoLayout.setHorizontalGroup(
            pnlClientInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlClientInfoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlClientInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlClientInfoLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel5))
                    .addGroup(pnlClientInfoLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6))
                    .addGroup(pnlClientInfoLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel7))
                    .addGroup(pnlClientInfoLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel8)))
                .addContainerGap(344, Short.MAX_VALUE))
        );
        pnlClientInfoLayout.setVerticalGroup(
            pnlClientInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlClientInfoLayout.createSequentialGroup()
                .addGroup(pnlClientInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlClientInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlClientInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlClientInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel8))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        BottomPanel.add(pnlClientInfo);

        jMenu1.setText("File");
        MainMenu.add(jMenu1);

        jMenu2.setText("Edit");
        MainMenu.add(jMenu2);

        setJMenuBar(MainMenu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(MainContent, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(BottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 1024, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(MainContent, javax.swing.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BottomPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                ClientProcessing clientMessenger = new ClientProcessing();
                new GameplayForm(clientMessenger).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel BottomPanel;
    private javax.swing.JTextArea ChatContent;
    private javax.swing.JPanel MainContent;
    private javax.swing.JMenuBar MainMenu;
    private javax.swing.JButton btnSend;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JPanel pnlChatting;
    private javax.swing.JPanel pnlClientInfo;
    private javax.swing.JTextField txtMessageInput;
    // End of variables declaration//GEN-END:variables
}
